package o;

import com.google.android.exoplayer2.ParserException;
import java.util.regex.Pattern;

public final class akq {
    private static final Pattern ˊ = Pattern.compile("^NOTE(( |\t).*)?$");

    public static void ˋ(anc o_anc) throws ParserException {
        int ˋ = o_anc.ˋ();
        if (!ॱ(o_anc)) {
            o_anc.ˋ(ˋ);
            throw new ParserException("Expected WEBVTT. Got " + o_anc.ˊˋ());
        }
    }

    public static boolean ॱ(anc o_anc) {
        String ˊˋ = o_anc.ˊˋ();
        return ˊˋ != null && ˊˋ.startsWith("WEBVTT");
    }

    public static long ॱ(String str) throws NumberFormatException {
        int i = 0;
        long j = 0;
        String[] ˊ = anr.ˊ(str, "\\.");
        String[] ˎ = anr.ˎ(ˊ[0], ":");
        while (i < ˎ.length) {
            j = (j * 60) + Long.parseLong(ˎ[i]);
            i++;
        }
        long j2 = j * 1000;
        if (ˊ.length == 2) {
            j2 += Long.parseLong(ˊ[1]);
        }
        return j2 * 1000;
    }

    public static float ˏ(String str) throws NumberFormatException {
        if (str.endsWith("%")) {
            return Float.parseFloat(str.substring(0, str.length() - 1)) / 100.0f;
        }
        throw new NumberFormatException("Percentages must end with %");
    }
}
